package FactoryMode;

import javafx.collections.FXCollections;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;

public class FactoryModeClient {

	public Scene getStage(){

		BorderPane borderPane = new BorderPane();
		borderPane.setPadding(new Insets(10, 0, 10, 20));
		Image image = new Image(getClass().getResourceAsStream("yyx.jpg"), 360, 250, false, false);
		ImageView imageView5 = new ImageView(image);

		FlowPane flowPane = new FlowPane();
		flowPane.setPadding(new Insets(0, 10, 10, 0));
		flowPane.setHgap(20);
		flowPane.setVgap(20);
		Text text1 = new Text("姓名：杨宜鑫");
		text1.setFont(Font.font("Verdana", FontWeight.BOLD, 20));
		Text text2 = new Text("学号：201627020125");
		text2.setFont(Font.font("Verdana", FontWeight.BOLD, 20));
		ChoiceBox cb5 = new ChoiceBox(FXCollections.observableArrayList("BodilyInjury",
				"AutomobileDamage", "Casualties", "MultipleAccidents"));
		String [] greeting = {"驾驶员身体受伤","汽车损坏","人员伤亡","多种事故",};
		Label label = new Label();
		label.setFont(new Font("Arial", 30));
		label.setPadding(new Insets(0, 0, 40, 20));
		cb5.getSelectionModel().selectedIndexProperty().addListener((ov,oldv,newv)->{
			label.setText(greeting[newv.intValue()]);
			if(greeting[newv.intValue()].equals("驾驶员身体受伤")){
				Factory factory;
				factory = new FactoryA();
				factory.createProduct().imformation();
			}
			else if(greeting[newv.intValue()].equals("汽车损坏")){
				Factory factory;
				factory = new FactoryB();
				factory.createProduct().imformation();
			}
			else if(greeting[newv.intValue()].equals("人员伤亡")){
				Factory factory;
				factory = new FactoryC();
				factory.createProduct().imformation();
			}
			else if(greeting[newv.intValue()].equals("多种事故")){
				Factory factory;
				factory = new FactoryD();
				factory.createProduct().imformation();
			}
		});
		flowPane.getChildren().addAll(text1, text2, cb5);

		borderPane.setLeft(imageView5);
		borderPane.setRight(flowPane);
		borderPane.setBottom(label);

		Scene scene = new Scene(borderPane, 900, 600);
		return scene;
	}
}
